<template>
    <div class="search">
        <Row :gutter="16" class="all-height">
            <Col :span="showRight ? 18 : 24" class="all-height">
                <Card class="all-height card-child-height">
                    <Row class="operation code-row-bg" style="display: flex; justify-content: space-between">
                        <Col span="22">
                            <Button v-has="'add'" @click="add" type="primary" icon="md-add">添加</Button>
                            <Button v-has="'delete'" @click="delAll" icon="md-trash">批量删除</Button>
                            <!--              <Button v-has="'output'" @click="dropExportData">导出所选数据</Button>-->
                            <!--              <Button v-has="'output'" @click="dropExportAll">导出全部数据</Button>-->
                            <!--              <Button v-has="'input'" @click="dropImportData">导入数据</Button>-->
                            <Button @click="getDataList" icon="md-refresh">刷新</Button>

                            <!--              <Button type="dashed" @click="openSearch=!openSearch">{{openSearch ? "关闭搜索" : "开启搜索"}}</Button>-->
                            <Button type="dashed" @click="openTip = !openTip">{{ openTip ? '关闭提示' : '开启提示' }}</Button>
                        </Col>
                        <Col span="2" style="text-align: right">
                            <Icon
                                color="#fff"
                                class="icon01"
                                :type="showRight ? `ios-arrow-forward` : `ios-arrow-back`"
                                @click.native="clickShowRight"
                            ></Icon>

                            <!--              <Button :icon="showRight?`ios-arrow-forward`:`ios-arrow-back`"-->
                            <!--                      @click.native="clickShowRight"-->
                            <!--                      type="primary">-->
                            <!--              </Button>-->
                        </Col>
                    </Row>
                    <Row v-show="openTip">
                        <Alert show-icon>
                            已选择
                            <span class="select-count">{{ selectList.length }}</span>
                            项
                            <a class="select-clear" @click="clearSelectAll">清空</a>
                        </Alert>
                    </Row>
                    <Row class="calc-px-height">
                        <Table
                            :loading="loading"
                            border
                            :columns="columns"
                            :data="data"
                            ref="table"
                            sortable="custom"
                            :height="height1"
                            @on-sort-change="changeSort"
                            @on-selection-change="changeSelect"
                            @on-row-dblclick="sjclaib"
                        ></Table>
                    </Row>
                    <Row type="flex" justify="end" class="page">
                        <Page
                            :current="searchForm.pageNumber"
                            :total="total"
                            :page-size="searchForm.pageSize"
                            @on-change="changePage"
                            @on-page-size-change="changePageSize"
                            :page-size-opts="[10, 20, 50, 100, 200]"
                            size="small"
                            show-total
                            show-elevator
                            show-sizer
                        ></Page>
                    </Row>
                </Card>
            </Col>
            <Col span="6" class="all-height" v-if="showRight">
                <Card class="all-height card-child-height">
                    <Row v-show="!modalVisible" @keydown.enter.native="handleSearch">
                        <Col span="24">
                            <div class="drawer-header">
                                <div class="cmr16">查询区</div>
                            </div>
                        </Col>
                        <Col span="24">
                            <Form ref="searchForm" :model="searchForm" :label-width="labelWidth95" class="marginForm">
                                <FormItem label="学历类型" prop="xllxz">
                                    <Select v-model="searchForm.xllxz" placeholder="请选择" clearable class="cw180" >
                                        <Option v-for="item in xlccDicts" :value="item.value">{{ item.title }}</Option>
                                    </Select>
                                </FormItem>
                                <FormItem label="学历代码" prop="xldm">
                                    <Input type="text" v-model="searchForm.xldm" placeholder="请输入学历代码" clearable  class="cw180" />
                                </FormItem>
                                <FormItem label="学历" prop="xl">
                                    <Input type="text" v-model="searchForm.xl" placeholder="请输入学历" clearable class="cw180" />
                                </FormItem>
                                <FormItem  class="br ">
                                    <Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
                                    <Button @click="handleReset">重置</Button>
                                    <!--                <a class="drop-down" @click="dropDown">-->
                                    <!--                  {{ dropDownContent }}-->
                                    <!--                  <Icon :type="dropDownIcon"></Icon>-->
                                    <!--                </a>-->
                                </FormItem>
                            </Form>
                        </Col>
                    </Row>
                    <Row class="calc-sm-height" v-show="modalVisible" style="flex-direction: column">
                        <!-- <Col span="24"> -->
                            <div class="drawer-header">
                                <div class="cmr16">{{ modalTitle }}</div>
                            </div>
                        <!-- </Col> -->
                        <!-- <Col span="24"> -->
                            <Form ref="form" :model="form" :rules="formValidate" :label-width="labelWidth100" label-position="right" class="marginForm">
                                <FormItem label="学历类型" prop="xllxz">
                                    <Select v-model="form.xllxz" clearable>
                                        <Option v-for="item in xlccDicts" :value="item.value">{{ item.title }}</Option>
                                    </Select>
                                </FormItem>
                                <FormItem label="学历代码" prop="xldm">
                                    <Input v-model="form.xldm" clearable maxlength="20" />
                                </FormItem>
                                <FormItem label="学历" prop="xl">
                                    <Input v-model="form.xl" clearable maxlength="50" />
                                </FormItem>
                            </Form>
                        <!-- </Col> -->
                        <div class="br right-bottom-edit">
                            <Button type="text" @click="modalVisible = false">取消</Button>
                            <div v-if="modalType == 0" style="display: inline">
                                <Button v-has="'add'" type="primary" :loading="submitLoading" @click="handleSubmit">提交</Button>
                            </div>
                            <div v-if="modalType == 1" style="display: inline">
                                <Button v-has="'edit'" type="primary" :loading="submitLoading" @click="handleSubmit">提交</Button>
                            </div>
                        </div>
                    </Row>
                </Card>
            </Col>
        </Row>

        <!--导入导出-->
        <Drawer title="导入数据" closable v-model="importModalVisible" class="c-drawer02">
            <div style="display: flex; justify-content: space-between; align-items: center">
                <Upload action :before-upload="beforeUploadImport" accept=".xls, .xlsx">
                    <Button :loading="reading" icon="ios-cloud-upload-outline"
                    class="cmr10">上传Excel文件</Button>
                    <span v-if="uploadfile.name">当前选择文件：{{ uploadfile.name }}</span>
                </Upload>
                <Button @click="clearImportData" icon="md-trash">清空数据</Button>
            </div>
            <Alert type="warning" show-icon>导入前请下载查看导入模版数据文件查看所需字段及说明，确保数据格式正确，不得修改列英文名称</Alert>
            <Table :columns="importColumns" border :height="height" :data="importTableData" ref="importTable"></Table>
            <div class="drawer-footer">
                <Button @click="downloadTemple" type="info">下载导入模板</Button>
                <div class="wrapper01" >
                    <Button @click="importModalVisible = false">关闭</Button>
                    <Button :loading="importLoading" :disabled="importTableData.length <= 0" @click="importData" class="cml8" type="primary">
                        确认导入
                        <span v-if="importTableData.length > 0">{{ importTableData.length }} 条数据</span>
                    </Button>
                </div>
            </div>
        </Drawer>

        <!-- 自定义导出数据 -->
        <Modal v-model="exportModalVisible" :title="exportTitle" :loading="loadingExport" @on-ok="exportCustomData">
            <Form ref="exportForm" :label-width="labelWidth100">
                <FormItem label="导出文件名">
                    <Input v-model="filename" />
                </FormItem>
                <FormItem label="自定义导出列">
                    <div class="wrapper03" >
                        <Checkbox :indeterminate="indeterminate" :value="checkAll" @click.prevent.native="handleCheckAll">全选</Checkbox>
                    </div>
                    <CheckboxGroup v-model="chooseColumns">
                        <Checkbox v-for="(item, i) in exportColumns" :label="item.title" :key="i" :value="item.checked" :disabled="item.disabled"></Checkbox>
                    </CheckboxGroup>
                </FormItem>
            </Form>
        </Modal>
        <!--table-->
        <Modal v-model="modal" :title="modalTableTitle" @on-ok="clickTrue">
            <Row>
                <Col>
                    <Table :columns="tableColumns" :data="dataList" :scroll="scroll" @on-row-dblclick="handleClickRow" style="overflow-y: scroll" ref="table"></Table>
                </Col>
            </Row>
        </Modal>
    </div>
</template>

<script>
// 根据你的实际请求api.js位置路径修改
import { getByPage, getXldmzdList, addXldmzd, editXldmzd, deleteXldmzd } from '@/api/bys/code/xldm.js';
import { getAllBysXjInfo, importData } from '@/api/bys/xj/bysXjInfo.js';
import { shortcuts } from '@/libs/shortcuts';
import { exportColumn } from '@/api/bys/xj/exportColumnXj.js';
import excel from '@/libs/excel';
import dict from '@/views/my-components/xboot/dict';
import { getDictDataByType } from '@/api/index';
import { getByXlAndLevel } from '@/api/bys/code.js';

export default {
    name: 'bysXjInfo',
    components: {
        dict
    },
    data() {
        return {
            labelWidth95: 95,
            labelWidth100: 100,
            // 导入导出
            importModalVisible: false,
            reading: false,
            importLoading: false,
            loadingExport: true,
            exportModalVisible: false,
            uploadfile: {
                name: ''
            },
            chooseColumns: [],
            filename: '基础信息',
            exportTitle: '确认导出',
            exportType: '',
            importTableData: [],
            importColumns: [],
            height: 510,
            exportData: [],
            exportColumns: exportColumn,
            indeterminate: false,
            checkAll: true,

            openSearch: true, // 显示搜索
            openTip: true, // 显示提示
            loading: true, // 表单加载状态
            modalType: 0, // 添加或编辑标识
            modalVisible: false, // 添加或编辑显示
            modalTitle: '', // 添加或编辑标题
            drop: false,
            dropDownContent: '展开',
            dropDownIcon: 'ios-arrow-down',
            height1: 0,
            searchForm: {
                // 搜索框初始化对象
                pageNumber: 1, // 当前页数
                pageSize: 50, // 页面大小
                sort: 'createTime', // 默认排序字段
                order: 'desc' // 默认排序方式
            },
            form: {
                // 添加或编辑表单对象初始化数据
                xllx: '',
                xldm: '',
                xl: ''
            },
            // 表单验证规则
            formValidate: {
                xllx: [{ required: true, message: '不能为空', trigger: 'change' }],
                xldm: [{ required: true, message: '不能为空', trigger: 'change' }],
                xl: [{ required: true, message: '不能为空', trigger: 'change' }]
            },
            submitLoading: false, // 添加或编辑提交状态
            selectList: [], // 多选数据
            columns: [],
            columns_1: Object.freeze([
                // 表头
                {
                    type: 'selection',
                    width: 70,
                    align: 'center'
                },
                {
                    type: 'index',
                    width: 70,
                    title: '序号',
                    align: 'center'
                },
                {
                    title: '学历类型',
                    key: 'xllx',
                    minWidth: 80,
                    sortable: false,
                    render: (h, params) => {
                        let dict = this.xlccDicts.find(item => item.value == params.row.xllxz).title;
                        return h('div', dict ? dict : '');
                    }
                },
                {
                    title: '学历代码',
                    key: 'xldm',
                    minWidth: 100,
                    sortable: false
                },
                {
                    title: '学历',
                    key: 'xl',
                    minWidth: 120,
                    sortable: false
                },

                {
                    title: '操作',
                    key: 'action',
                    align: 'center',
                    width: 120,
                    render: (h, params) => {
                        return h('div', [
                            h(
                                'a',
                                {
                                    style: {
                                        display: this.hasPermission(this, 'edit') ? 'inline-block' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                            this.edit(params.row);
                                        }
                                    }
                                },
                                '编辑'
                            ),
                            h('Divider', {
                                props: {
                                    type: 'vertical'
                                },
                                style: {
                                    display: this.hasPermission(this, 'delete') ? 'inline-block' : 'none'
                                }
                            }),
                            h(
                                'a',
                                {
                                    style: {
                                        display: this.hasPermission(this, 'delete') ? 'inline-block' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                            this.remove(params.row);
                                        }
                                    }
                                },
                                '删除'
                            )
                        ]);
                    }
                }
            ]),
            data: [], // 表单数据
            total: 0, // 表单数据总数
            showRight: true,
            dataList: [],
            scroll: {
                y: '200px' // 表头固定的高度
            },
            // 弹框
            modal: false,
            modalTableTitle: '',
            tableColumns: [
                {
                    title: '',
                    key: 'value',
                    sortable: false,
                    align: 'center'
                },
                {
                    title: '名称',
                    key: 'title',
                    sortable: false,
                    align: 'center'
                }
            ],
            modalDict: '',
            showCode: '', //双击行传递的值
            rowList: null,
            xlccDicts: [],
            xbList: [],
            mzList: [],
            zzmmList: [],
            xlList: [],
            pyfsList: [],
            knslbList: [],
            sfslbList: [],
            gzkzksbzList: [],
            xxxs: []
        };
    },
    watch: {
        modalDict(val) {
            console.log(val, '---cal');
            // this.getData(val);
        }
    },
    methods: {
        tableheig() {
            var bbb = document.getElementsByClassName('calc-px-height')[0].scrollHeight;
            var aaa = document.getElementsByClassName('calc-px-height')[0].children[0].children[0].children[1];
            var ccc = document.getElementsByClassName('calc-px-height')[0].children[0].children[0].children[0].scrollHeight;
            var ddd = bbb - ccc;
            console.log(bbb, '00000000000000');
            aaa.style.height = `${ddd}px`;

            if (this.searchForm.pageSize === 10) {
                this.height1 = 0;
            } else {
                this.height1 = document.getElementsByClassName('calc-px-height')[0].scrollHeight;
                if (this.total < this.searchForm.pageNumber * this.searchForm.pageSize) {
                    var r = (this.searchForm.pageNumber - 1) * this.searchForm.pageSize;
                    var a = this.total - r;
                    var s = a * 43 + 65;
                    if (s < this.height1) {
                        this.height1 = 0;
                    }
                }
            }
            if (this.total < 10) {
                this.height1 = 0;
            }
        },
        init() {
            // this.getData('sex')
            this.getDataList();
            this.getDictData();
        },
        //字典
        getDictData() {
            // 学历层次
            getDictDataByType('eduLevelType').then(res => {
                if (res.success) {
                    this.xlccDicts = res.result;
                    console.log("this.xlccDicts ",this.xlccDicts )
                }
            });
        },
        getZydm() {
            getByXlAndLevel({ gradLevelDict: this.form.cc, level: '2' }).then(res => {
                if (res.success) {
                    this.dataList = res.result.map(e => {
                        return {
                            title: e.title,
                            value: e.profCode
                        };
                    });
                    console.log(this.dataList, '----list');
                }
            });
        },
        getData(v) {
            getDictDataByType('sex').then(res => {
                if (res.success) {
                    this.xbList = res.result;
                }
            });
            getDictDataByType('ethnic').then(res => {
                if (res.success) {
                    this.mzList = res.result;
                }
            });
            getDictDataByType('political').then(res => {
                if (res.success) {
                    this.zzmmList = res.result;
                }
            });
            getDictDataByType('degree').then(res => {
                if (res.success) {
                    this.xlList = res.result;
                }
            });
            getDictDataByType('training-methods').then(res => {
                if (res.success) {
                    this.pyfsList = res.result;
                }
            });
            getDictDataByType('difficult-student-category').then(res => {
                if (res.success) {
                    this.knslbList = res.result;
                }
            });
            getDictDataByType('sfs_type').then(res => {
                if (res.success) {
                    this.sfslbList = res.result;
                }
            });
            getDictDataByType('higher-voc-ex-exam').then(res => {
                if (res.success) {
                    this.gzkzksbzList = res.result;
                }
            });
            getDictDataByType('learning-forms').then(res => {
                if (res.success) {
                    this.xxxsList = res.result;
                }
            });

            // if(v=='sex'){
            //
            // }
            getDictDataByType(v).then(res => {
                if (res.success) {
                    this.dataList = res.result;
                    console.log(this.dataList, '----list');
                }
            });
        },
        // 显示隐藏右侧区域
        clickShowRight() {
            this.showRight = !this.showRight;
        },
        keyUpSearch(e, value) {
            this.showDict(value);
            if (e.keyCode == 13 || e.keyCode == 9) {
                if (value == 'xbdm') {
                    this.form.xbdm = this.xbList.find(item => item.value == e.target.value).title;
                } else if (value == 'mzdm') {
                    this.form.mzdm = this.mzList.find(item => item.value == e.target.value).title;
                } else if (value == 'zzmmList') {
                    this.form.zzmmdm = this.zzmmList.find(item => item.value == e.target.value).title;
                } else if (value == 'xldm') {
                    this.form.xldm = this.xlList.find(item => item.value == e.target.value).title;
                } else if ('pyfsdm') {
                    this.form.pyfsdm = this.pyfsList.find(item => item.value == e.target.value).title;
                } else if ('knslbdm') {
                    this.form.knslbdm = this.knslbList.find(item => item.value == e.target.value).title;
                } else if ('sfslbdm') {
                    this.form.sfslbdm = this.sfslbList.find(item => item.value == e.target.value).title;
                } else if ('gzkzksbz') {
                    this.form.gzkzksbz = this.gzkzksbzList.find(item => item.value == e.target.value).title;
                } else if ('xxxs') {
                    this.form.xxxs = this.xxxsList.find(item => item.value == e.target.value).title;
                }
            }
        },
        //代码按钮
        clickSexCode(e) {
            if (e == 'zydm') {
                if (this.form.cc == null || this.form.cc == undefined || this.form.cc == '') {
                    // this.$Message.error("请先选择学历层次!")
                    this.$Message.error({
                        content: '请先选择学历层次!',
                        duration: 5,
                        closable: true
                    });
                } else {
                    this.showCode = e;
                    this.showDict(e);
                    this.modal = true;
                }
            } else {
                this.showCode = e;
                this.showDict(e);
                this.modal = true;
            }
        },
        showDict(e) {
            if (e == 'xbdm') {
                this.modalTableTitle = '性别';
                this.modalDict = 'sex';
            } else if (e == 'mzdm') {
                this.modalTableTitle = '民族';
                this.modalDict = 'ethnic';
            } else if (e == 'zzmmdm') {
                this.modalTableTitle = '政治面貌';
                this.modalDict = 'political';
            } else if (e == 'xldm') {
                this.modalTableTitle = '学历';
                this.modalDict = 'degree';
            } else if (e == 'zydm') {
                console.log(this.form.cc, 'this.form.xlcc');
                if (this.form.cc == null || this.form.cc == undefined || this.form.cc == '') {
                    // this.$Message.error("请先选择学历层次!")
                    this.$Message.error({
                        content: '请先选择学历层次!',
                        duration: 5,
                        closable: true
                    });
                } else {
                    this.modalTableTitle = '专业';
                    this.getZydm();
                }
            } else if (e == 'pyfsdm') {
                this.modalTableTitle = '培养方式';
                this.modalDict = 'training-methods';
            } else if (e == 'knslbdm') {
                this.modalTableTitle = '困难生类别';
                this.modalDict = 'difficult-student-category';
                // this.modal = true
            } else if (e == 'sfslbdm') {
                this.modalTableTitle = '师范生类别';
                this.modalDict = 'sfs_type';
            } else if (e == 'gzkzksbz') {
                this.modalTableTitle = '高职扩招考试标志';
                this.modalDict = 'higher-voc-ex-exam';
            } else if (e == 'xxxs') {
                this.modalTableTitle = '学习形式';
                this.modalDict = 'learning-forms';
            }
            // else if (e == 'byqxdm') {
            //   this.modalTableTitle = '毕业生去向'
            //   this.modalDict = 'bys-destination'
            //
            // }
            else if (e == 'dwxzdm') {
                this.modalTableTitle = '单位性质';
                this.modalDict = 'unit-nature';
                this.modal = true;
            } else if (e == 'dwhydm') {
                this.modalTableTitle = '单位行业';
                this.modalDict = 'unit-industry';
            } else if (e == 'gzzwlbdm') {
                this.modalTableTitle = '工业职位类型';
                this.modalDict = 'job-position-category';
            } else if (e == 'xz') {
                this.modalTableTitle = '学制';
                this.modalDict = 'educational-system';
            }
        },
        //弹框按钮
        clickTrue() {
            this.modal = false;
            // this.form[this.showCode] = this.rowList.title
        },
        // table
        handleClickRow(row) {
            console.log(row);
            this.rowList = row;
            this.clickTrue();
        },
        //导入导出

        // 读取文件
        readFile(file) {
            this.reading = true;
            const reader = new FileReader();
            reader.readAsArrayBuffer(file);
            reader.onerror = e => {
                this.reading = false;
                // this.$Message.error("文件读取出错");
                this.$Message.error({
                    content: '文件读取出错',
                    duration: 5,
                    closable: true
                });
            };
            reader.onload = e => {
                const data = e.target.result;
                const { header, results } = excel.read(data, 'array');
                const tableTitle = header.map(item => {
                    return { title: item, key: item, minWidth: 130, align: 'center' };
                });
                this.importTableData = results;
                this.importColumns = tableTitle;
                this.reading = false;
                this.$Message.success('读取数据成功');
            };
        },

        // 全选
        handleCheckAll() {
            this.indeterminate = !this.indeterminate;
            this.checkAll = !this.checkAll;
            if (this.checkAll) {
                this.chooseColumns = this.exportColumns.map(el => el.title);
            } else {
                this.chooseColumns = [];
            }
        },
        exportCustomData() {
            if (this.filename == '') {
                this.filename = '基础信息';
            }
            // 判断勾选导出列
            let array = [];
            this.exportColumns.forEach(e => {
                this.chooseColumns.forEach(c => {
                    if (e.title == c && !e.disabled) {
                        array.push(e);
                    }
                });
            });
            this.exportColumns = array;
            this.exportModalVisible = false;
            let title = [];
            let key = [];
            this.exportColumns.forEach(e => {
                title.push(e.title);
                key.push(e.key);
            });
            const params = {
                title: title,
                key: key,
                data: this.exportData,
                autoWidth: true,
                filename: this.filename
            };
            excel.export_array_to_excel(params);
        },

        //导出所选数据
        dropExportData() {
            if (this.selectList.length <= 0) {
                this.$Message.warning('您还未选择要导出的数据');
                return;
            }
            this.chooseColumns = this.exportColumns.map(el => el.title);
            this.exportType = 'part';
            this.exportModalVisible = true;
            this.exportTitle = '确认导出 ' + this.selectList.length + ' 条数据';
            this.exportData = this.selectList;
            // "确认导出 " + this.selectList.length + " 条数据(付费)";
        },
        //导出全部数据
        dropExportAll() {
            this.exportType = 'all';
            this.chooseColumns = this.exportColumns.map(el => el.title);
            console.log(this.chooseColumns, '1111111');
            this.exportModalVisible = true;
            this.exportTitle = '确认导出全部 ' + this.total + ' 条数据';
            // this.exportTitle = "确认导出全部 " + this.total + " 条数据(付费)";
            getAllBysXjInfo().then(res => {
                if (res.success) {
                    this.exportData = res.result;
                }
            });
        },

        importData() {
            let params = this.importTableData.map(item => {
                return {
                    yxdm: item['院校代码'],
                    yxmc: item['院校名称'],
                    ksh: item['考生号'],
                    sfzh: item['身份证号'],
                    xh: item['学号'],
                    xm: item['姓名'],
                    xbdm: item['性别代码'],
                    mzdm: item['民族代码'],
                    zzmmdm: item['政治面貌代码'],
                    xldm: item['学历代码'],
                    zydm: item['专业代码'],
                    zy: item['专业'],
                    zyfx: item['专业方向'],
                    pyfsdm: item['培养方式代码'],
                    syszddm: item['生源所在地代码'],
                    // dxhwpdw: item['定向或委培单位'],
                    xz: item['学制'],
                    rxsj: item['入学时间'],
                    bysj: item['毕业时间'],
                    knslbdm: item['困难生类别代码'],
                    sfslbdm: item['师范生类别代码'],
                    // byqxdm: item['毕业去向代码'],
                    // dwzzjgdm: item['单位组织机构代码'],
                    // dwmc: item['单位名称'],
                    // dwxzdm: item['单位性质代码'],
                    // dwhydm: item['单位行业代码'],
                    // dwszddm: item['单位所在地代码'],
                    // gzzwlbdm: item['工作职位类别代码'],
                    // bdzqflbdm: item['报到证签发类别代码'],
                    // bdzqwdwmc: item['报到证签往单位名称'],
                    // qwdwszddm: item['签往单位所在地代码'],
                    // bdzbh: item['报到证编号'],
                    // bdqssj: item['报到起始时间'],
                    cx: item['城乡'],
                    cc: item['学历层次'],
                    fy: item['分院'],
                    xsh: item['院系名称'],
                    // xshdm: item['院系代码'],
                    dxwpdwszdm: item['定向委培单位所在地代码'],
                    dxwpdw: item['定向委培单位名称'],
                    sfjdlk: item['是否建档立卡'],
                    gzkzksbz: item['高职扩招考试标志'],
                    xxxs: item['学习形式']
                };
            });
            this.importLoading = true;
            importData(params).then(res => {
                this.importLoading = false;
                if (res.success) {
                    this.importModalVisible = false;
                    this.getDataList();
                    this.$Modal.info({
                        title: '导入结果',
                        content: res.message
                    });
                }
            });
        },
        downloadTemple() {
            window.location.href = process.env.BASE_URL + '基础信息导入模板.xlsx';
        },
        clearImportData() {
            this.importTableData = [];
            this.importColumns = [];
            this.uploadfile = {};
        },
        //导入数据
        dropImportData() {
            this.importModalVisible = true;
        },
        beforeUploadImport(file) {
            this.uploadfile = file;
            const fileExt = file.name.split('.').pop().toLocaleLowerCase();
            if (fileExt == 'xlsx' || fileExt == 'xls') {
                this.readFile(file);
                this.file = file;
            } else {
                this.$Notice.warning({
                    title: '文件类型错误',
                    desc: '所选文件‘ ' + file.name + ' ’不是EXCEL文件，请选择后缀为.xlsx或者.xls的EXCEL文件。'
                });
            }
            return false;
        },
        changePage(v) {
            this.searchForm.pageNumber = v;
            this.getDataList();
            this.clearSelectAll();
        },
        changePageSize(v) {
            this.searchForm.pageSize = v;
            this.getDataList();
        },
        handleSearch() {
            this.searchForm.pageNumber = 1;
            this.searchForm.pageSize = 50;
            this.getDataList();
        },
        handleReset() {
            this.$refs.searchForm.resetFields();
            this.searchForm.pageNumber = 1;
            this.searchForm.pageSize = 50;
            // 重新加载数据
            this.getDataList();
        },
        changeSort(e) {
            this.searchForm.sort = e.key;
            this.searchForm.order = e.order;
            if (e.order === 'normal') {
                this.searchForm.order = '';
            }
            this.getDataList();
        },
        clearSelectAll() {
            this.$refs.table.selectAll(false);
        },
        changeSelect(e) {
            this.selectList = e;
        },
        dropDown() {
            if (this.drop) {
                this.dropDownContent = '展开';
                this.dropDownIcon = 'ios-arrow-down';
            } else {
                this.dropDownContent = '收起';
                this.dropDownIcon = 'ios-arrow-up';
            }
            this.drop = !this.drop;
        },
        async getDataList() {
            this.loading = true;
            let res = await this.postRequest('/xldmzd/getByPage', this.searchForm);
            this.loading = false;
            if (res.success) {
                this.data = res.result.records;
                this.total = res.result.total;
                console.log("this.data",this.data)
                this.tableheig();
            }
        },
        // getDataList() {
        //     this.loading = true;
        //     getXldmzdList(this.searchForm).then(res => {
        //         this.loading = false;
        //         if (res.success) {
        //             this.data = res.result.records;
        //             this.total = res.result.total;
        //             if (this.data.length == 0 && this.searchForm.pageNumber > 1) {
        //                 this.searchForm.pageNumber -= 1;
        //                 this.getDataList();
        //             }
        //         }
        //     });
        // },
        handleSubmit() {
            this.$refs.form.validate(valid => {
                if (valid) {
                    this.submitLoading = true;
                    if (this.modalType === 0) {
                        // 添加 避免编辑后传入id等数据 记得删除
                        delete this.form.id;
                        addXldmzd(this.form).then(res => {
                            this.submitLoading = false;
                            if (res.success) {
                                this.$Message.success('操作成功');
                                this.getDataList();
                                this.modalVisible = false;
                            }
                        });
                    } else {
                        // 编辑
                        editXldmzd(this.form).then(res => {
                            this.submitLoading = false;
                            if (res.success) {
                                this.$Message.success('操作成功');
                                this.getDataList();
                                this.modalVisible = false;
                            }
                        });
                    }
                }
            });
        },
        add() {
            this.modalType = 0;
            this.modalTitle = '添加';
            this.$refs.form.resetFields();
            delete this.form.id;
            this.modalVisible = true;
        },
        // 双击表格行
        sjclaib(v) {
            this.modalType = 1;
            this.modalTitle = '编辑';
            this.$refs.form.resetFields();
            // 转换null为""
            for (let attr in v) {
                if (v[attr] === null) {
                    v[attr] = '';
                }
            }
            let str = JSON.stringify(v);
            let data = JSON.parse(str);
            this.form = data;
            this.modalVisible = true;
        },
        edit(v) {
            this.modalType = 1;
            this.modalTitle = '编辑';
            this.$refs.form.resetFields();
            // 转换null为""
            for (let attr in v) {
                if (v[attr] === null) {
                    v[attr] = '';
                }
            }
            let str = JSON.stringify(v);
            let data = JSON.parse(str);
            this.form = data;
            this.modalVisible = true;
        },
        remove(v) {
            this.$Modal.confirm({
                title: '确认删除',
                // 记得确认修改此处
                content: '您确认要删除该条数据?',
                loading: true,
                onOk: () => {
                    // 删除
                    deleteXldmzd({ ids: v.id }).then(res => {
                        this.$Modal.remove();
                        if (res.success) {
                            this.$Message.success('操作成功');
                            this.clearSelectAll();
                            this.getDataList();
                        }
                    });
                }
            });
        },
        delAll() {
            if (this.selectList.length <= 0) {
                this.$Message.warning('您还未选择要删除的数据');
                return;
            }
            this.$Modal.confirm({
                title: '确认删除',
                content: '您确认要删除所选的 ' + this.selectList.length + ' 条数据?',
                loading: true,
                onOk: () => {
                    let ids = '';
                    this.selectList.forEach(function (e) {
                        ids += e.id + ',';
                    });
                    ids = ids.substring(0, ids.length - 1);
                    // 批量删除
                    deleteBysXjInfo({ ids: ids }).then(res => {
                        this.$Modal.remove();
                        if (res.success) {
                            this.$Message.success('操作成功');
                            this.clearSelectAll();
                            this.getDataList();
                        }
                    });
                }
            });
        },
        onRestWindow() {
            this.columns = this.restTableCellWidth(this.columns_1)
            this.labelWidth95 = this.searchLabelWidth(this.labelWidth95)
            this.labelWidth100 = this.searchLabelWidth(this.labelWidth100)
        }
    },
    mounted() {
        this.onRestWindow()
        window.addEventListener('resize',this.onRestWindow)
        // 计算高度
        this.height = Number(document.documentElement.clientHeight - 230);
        this.init();
    },
    beforeDestroy() {
        window.removeEventListener('resize',this.onRestWindow)
    }
};
</script>
<style lang="less" scoped>
/deep/ .ivu-select-dropdown {
    // display: none;
}

.ivu-input-prefix {
    top: 0.03rem;
}

.itemLabel {
    span {
        color: rgb(55, 140, 254) !important;
        cursor: pointer;
    }
}

.selected {
    background-color: #f5f7fa;
}

/deep/ .ivu-table {
    .ivu-table-body {
        //height: 450px !important;
        overflow-y: scroll;

        .ivu-table-row {
            &:hover {
                .ivu-input {
                    background: rgb(235, 247, 255);
                }
            }
        }

        .ivu-input {
            border: none !important;
            cursor: default;

            &:hover {
                border: none !important;
                background: rgb(235, 247, 255);
            }
        }
    }
}
</style>
<style lang="less">
// 建议引入通用样式 具体路径自行修改 可删除下面样式代码
@import '../../../styles/table-common.less';
@import '../../personInfo.less';

.search {
    .operation {
        margin-bottom: 2vh;
    }

    .select-count {
        font-weight: 600;
        color: #40a9ff;
    }

    .select-clear {
        margin-left: 10px;
    }

    .page {
        margin-top: 2vh;
    }

    .drop-down {
        margin-left: 5px;
    }
}
</style>
<style lang="less" scoped>
.icon01 {
    background: rgb(45, 154, 244); border-radius: 50%; padding: 3px
}
.cmr16{
    margin-right: 16px
}
.cmr10 {
    margin-right: 10px 
}
.cml-35 {
    margin-left: -35px;
}
.c-drawer02 {
    /deep/ .ivu-drawer {
        width:1000px !important;
    }
    
}
.wrapper01 {
    position: absolute; right: 15px; display: inline-block
}
.wrapper03 {
    border-bottom: 1px solid #e9e9e9; padding-bottom: 6px; margin-bottom: 6px
}
.cml8{
    margin-left: 8px
}
.cw180 {
    width: 180px;
}
</style>